
const calc = require('./calculator.js');

let argv  = process.argv.slice(2);

validateLength(argv);

let param1 = argv[0];
let operator = argv[1];
let param2 = argv[2];

let result = 0;

switch(operator){
    case '+':
            // result= parseFloat(param1) + parseFloat(param2);
            result = calc.add(param1,param2);
            console.log(result);
        break;
    case '-':
            // result= parseFloat(param1) - parseFloat(param2);
            result = calc.sub(param1,param2);
            console.log(result);
        break;
    case '*':
            // result= parseFloat(param1) * parseFloat(param2);
            result = calc.mul(param1,param2);
            console.log(result);
        break;
    case '/':
            // result= parseFloat(param1) / parseFloat(param2);
            result = calc.div(param1,param2);
            console.log(result);
        break;
    case '%':
            // result= parseFloat(param1) % parseFloat(param2);
            result = calc.yu(param1,param2);
            console.log(result);
        break;
    default:
        console.log('参数位数不正确');
        break;
}



function validateLength(argv){
    if(argv.length <3){
        console.log('参数小于3位');
        
    }
}